const { contextBridge, ipcRenderer } = require('electron');

contextBridge.exposeInMainWorld('baoyiElectronApi', {
  startAutoCollect: (data) => {
    ipcRenderer.send('start-auto-collect', data);
  },
  onFromChildWebContentFinishTask: (callback) => {
    ipcRenderer.on('from-child-web-content-finish-task', (event, args) =>
      callback(args),
    );
  },
  onUpdateAvailable: (callback) => {
    ipcRenderer.on('update-available', (event, args) => callback(args));
  },
  onUpdateNotAvailable: (callback) => {
    ipcRenderer.on('update-not-available', (event, args) => callback(args));
  },
  onDownloadProgress: (callback) => {
    ipcRenderer.on('download-progress', (event, args) => callback(args));
  },
  onUpdateDownloaded: (callback) => {
    ipcRenderer.on('update-downloaded', (event, args) => callback(args));
  },
});
